import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../app_session.dart';

/// 主Tab控制器
class MainTabController extends GetxController {
  final RxInt currentIndex = 0.obs;

  final RxBool isHuodaiYunshu = false.obs;
  /// 切换Tab
  void changeTabIndex(int index) {
    currentIndex.value = index;
  }
  
  @override
  void onInit() {
    super.onInit();
    
    // 延迟到构建完成后执行语言切换，避免在构建过程中调用setState
    WidgetsBinding.instance.addPostFrameCallback((_) {
      if (app.isLangRU()) {
        app.translationToRU();
      } else {
        app.translationToCN();
      }
      isHuodaiYunshu.value = app.getUser()?.isHuodaiOrYunshu() ?? false;
    });
  }
}
